<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class VipOrder extends Model
{
    const STATUS = [ '0' => '未支付', '1' => '已支付', '2' => '支付中', '3' => '支付失败'];
    const PAY_TYPE = [ '0' => '未支付', '1' => '微信支付', '2' => '支付宝', '3' => '线下支付'];
    public $timestamps = false;
    protected $connection = 'xz';
    protected $table = 'vip_order';
    use HasFactory;

    public function user()
    {
        return $this->hasOne('App\Models\Platform_user','id','uid');
    }

    public function vip()
    {
        return $this->hasOne('App\Models\AppVip','id','vip_id');
    }

    public function getStatusAttribute(string $value)
    {
        return self::STATUS[$value];
    }

    public function getPayTypeAttribute(string $value)
    {
        return self::PAY_TYPE[$value];
    }

    /**
     *  获取日期.
     *
     * @param string $value
     * @return string
     */
    public function getCreateTimeAttribute(string $value)
    {
        return Date("Y-m-d H:i:s",$value);
    }

}
